home *** CD-ROM | disk | FTP | other *** search
/ Risc World 3 / Risc World 3.iso / SOFTWARE / ISSUE2 / FASTERPC / DRIVE_C / GAMES / #IM / GRAPHICS / VGA / VGA.SRC < prev   
Text File  |  1993-04-27  |  4KB  |  130 lines

  1.          ; Test program for !FasterPC
  2.          ; Copyright D.J.Lawrence, 1993
  3.          ;
  4.          ; This test program loads a VGA mode 13 screen and scrolls
  5.          ; it horizontally, as fast as it can. The program continues
  6.          ; until the screen has scrolled once or until the user
  7.          ; presses any key.
  8.  
  9. Code_Seg SEGMENT PUBLIC
  10.  
  11.          ASSUME CS:Code_Seg
  12.          ORG   00100H            ; Produce a '.COM' executable
  13.  
  14.          MOV   AX,0013H
  15.          INT   10H               ; Mode 13H (VGA 256 colours)
  16.          MOV   AX,3D00H
  17.          PUSH  CS
  18.          POP   DS
  19.          MOV   DX,OFFSET PalName
  20.          INT   21H               ; Open palette file
  21.          MOV   FHandle,AX
  22.          MOV   BX,FHandle
  23.          MOV   AX,3F00H
  24.          MOV   CX,0300H          ; Read 768 bytes (3 registers * 256 colours)
  25.          MOV   DX,OFFSET DataArea
  26.          INT   21H               ; Read palette file into memory
  27.          MOV   BX,FHandle
  28.          MOV   AX,3E00H
  29.          INT   21H               ; Close palette file
  30.  
  31.          ; Convert 8 bit palette values to 6 bit values by shifting right 2
  32.          PUSH  CS
  33.          POP   DS
  34.          MOV   SI,OFFSET DataArea
  35.          MOV   CX,0300H
  36. ModLP1:  MOV   AL,[SI]
  37.          SHR   AL,1
  38.          SHR   AL,1
  39.          MOV   [SI],AL
  40.          INC   SI
  41.          LOOP  ModLP1
  42.  
  43.          ; Update palette registers with shifted palette values
  44.          MOV   AX,1012H
  45.          MOV   BX,0000H
  46.          MOV   CX,0100H
  47.          PUSH  CS
  48.          POP   ES
  49.          MOV   DX,OFFSET DataArea
  50.          INT   10H
  51.  
  52.          ; Load picture file into video memory
  53.          PUSH  CS
  54.          POP   DS
  55.          MOV   AX,3D00H
  56.          MOV   DX,OFFSET PicName
  57.          INT   21H               ; Open picture file
  58.          MOV   FHandle,AX
  59.          MOV   BX,FHandle
  60.          MOV   AX,0A000H
  61.          PUSH  AX
  62.          POP   DS
  63.          MOV   AX,3F00H
  64.          MOV   CX,0FA00H         ; Read 64000 bytes
  65.          MOV   DX,0000H
  66.          INT   21H               ; Read picture file into video memory
  67.          MOV   BX,FHandle
  68.          MOV   AX,3E00H
  69.          INT   21H               ; Close picture file
  70.  
  71.          ; Perform the screen scroll for 320 pixels
  72.          ; or until the user presses a key
  73.          ; Initialise the 320 counter
  74.          MOV   BX,0140H
  75.          ; First store the left most pixel column
  76. LScroll: MOV   AX,0A000H
  77.          PUSH  CS
  78.          PUSH  AX
  79.          POP   DS                ; DS = A000
  80.          POP   ES                ; ES = CS
  81.          MOV   SI,0000H
  82.          MOV   DI,OFFSET DataArea
  83.          MOV   CX,00C8H          ; Repeat for all 200 screen pixel lines
  84. MovLP1:  MOVSB         
  85.          ADD   SI,013FH          ; Move source to start of next pixel row
  86.          LOOP  MovLP1
  87.          ; Next scroll the whole screen left by one pixel
  88.          MOV   AX,0A000H
  89.          PUSH  AX
  90.          POP   ES                ; ES = A000
  91.          MOV   SI,0001H
  92.          MOV   DI,0000H
  93.          MOV   CX,08000H
  94.          REP   MOVSW             ; Scroll using word move for max efficiency
  95.          ; Restore the right most pixel column
  96.          MOV   AX,0A000H
  97.          PUSH  AX
  98.          PUSH  CS
  99.          POP   DS                ; DS = CS
  100.          POP   ES                ; ES = A000
  101.          MOV   SI,OFFSET DataArea
  102.          MOV   DI,013FH
  103.          MOV   CX,00C8H
  104. MovLP2:  MOVSB         
  105.          ADD   DI,013FH
  106.          LOOP  MovLP2
  107.  
  108.          ; See if the 320 columns have been completed
  109.          DEC   BX
  110.          CMP   BX,0000H
  111.          JE    Quit2
  112.          
  113.          ; See if user wants to exit
  114.          MOV   AX,0100H
  115.          INT   16H               ; Has a key has been pressed ?
  116.          JNE   Quit1             ; Yes - jump
  117.          JMP   LScroll           ; No  - continue scroll
  118. Quit1:   MOV   AX,0000H
  119.          INT   16H               ; Read the detected key
  120. Quit2:   MOV   AX,0003H
  121.          INT   10H               ; Mode 3 (CGA colour text) 
  122.          RET
  123.  
  124. FHandle  DW ?
  125. PalName  DB 'VGA.PAL',0
  126. PicName  DB 'VGA.PIC',0
  127. DataArea DB 768 DUP ?
  128.  
  129. Code_Seg ENDS
  130.